FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

do_patch() {
        # add multiple core boot patches
        if ${@bb.utils.contains('SUPPORT_MULTICORE_BOOT', '1', 'true', 'false', d)}; then

        fi

        # add pfe-slave patch
        if ${@bb.utils.contains('DISTRO_FEATURES', 'pfe-slave', 'true', 'false', d)}; then
                file = "patch_1.patch"
                patch_file = "${WORKDIR}/$file"
                dest_file = "${S}/$file"
                cp $patch_file $dest_file
                patch -p1 < $dest_file
        fi

        for file in *.patch; do
                patch_file = "${WORKDIR}/$file"
                dest_file = "${S}/$file"
                if [ -e $patch_file ]; then
                        cp $patch_file $dest_file
                        patch -p1 < $dest_file
                fi
        done
}

addtask patch after do_unpack before do_configure

do_compile() {
        unset LDFLAGS
        unset CFLAGS
        unset CPPFLAGS

        oe_runmake -C "${S}" clean

        for suffix in ${BOOT_TYPE}
        do
                oe_runmake -C "${S}" \
                        BL33="${DEPLOY_DIR_IMAGE}/u-boot-nodtb.bin-${suffix}" \
                        MKIMAGE="mkimage" \
                        BL33DIR="${DEPLOY_DIR_IMAGE}/tools/" \
                        MKIMAGE_CFG="${DEPLOY_DIR_IMAGE}/tools/u-boot-s32.cfgout-${suffix}" all
                cp -vf "${ATF_BINARIES}/fip.bin" "${ATF_BINARIES}/fip.bin-${suffix}"
                cp -vf "${ATF_BINARIES}/fip.s32" "${ATF_BINARIES}/fip.s32-${suffix}"
        done
}

do_deploy() {
	install -d ${DEPLOYDIR}
	for suffix in ${BOOT_TYPE}; do
                cp -vf "${ATF_BINARIES}/fip.bin-${suffix}" ${DEPLOYDIR}
		cp -vf "${ATF_BINARIES}/fip.s32-${suffix}" ${DEPLOYDIR}
	done
}

addtask deploy after do_compile